<!DOCTYPE html>
<html lang="en" th:replace="~{modules/layouts/layout :: layout(content = ~{::content}, htmlType = 'tag')}"
      xmlns:th="http://www.thymeleaf.org">

<th:block th:fragment="content">

    <div class="page" id="body-wrap">
        <header class="not-top-img" id="page-header">
            <nav th:replace="~{modules/nav :: nav}"></nav>
        </header>
        <main class="layout" id="content-inner">
            <div id="tag">
                <div id="tag-page-tags" th:with="tags = ${tagFinder.listAll()}">
                    <a style="font-size:1em;color:#3c228c"
                       th:classappend="${tag.metadata.name == tagItem.metadata.name} ? 'select'"
                       th:each="tagItem : ${tags}"
                       th:href="@{${tagItem.status.permalink}}"
                       th:id="${tagItem.spec.displayName}">
                        <span class="tags-punctuation">#</span> [[${tagItem.spec.displayName}]]
                        <span class="tagsPageCount" th:text="${tagItem.status.visiblePostCount}"></span>
                    </a>
                </div>
                <div class="article-sort-title" th:text="${tag.spec.displayName}"></div>
                <div class="article-sort" th:with="postItems=${posts.items}">
                    <!--<div class="article-sort-item year">2022</div>-->
                    <div class="article-sort-item" th:each="post : ${postItems}"
                         th:with='postRandomImg=${#strings.contains(theme.config.layout.postRandomImg,"?") ? theme.config.layout.postRandomImg+"," : theme.config.layout.postRandomImg+"?"}'>
                        <a class="article-sort-item-img" th:href="@{${post.status.permalink}}"
                           th:title="${post.spec.title}">
                            <img loading="lazy" th:alt="${post.status.excerpt}"
                                 th:src="${#strings.isEmpty(post.spec.cover) ? postRandomImg+post.spec.title : post.spec.cover}">
                        </a>
                        <div class="article-sort-item-info">
                            <div class="article-sort-item-time"><i class="far fa-calendar-alt"></i>
                                <time th:text="${#dates.format(post.spec.publishTime,'yyyy-MM-dd')}"
                                      th:title="${#dates.format(post.spec.publishTime,'yyyy-MM-dd')}">
                                </time>
                            </div>
                            <a class="article-sort-item-title" onclick="window.event.cancelBubble=!0"
                               th:href="@{${post.status.permalink}}"
                               th:text="${post.spec.title}" th:title="${post.spec.title}">
                            </a>
                            <div class="article-sort-item-tags">
                                <a class="article-meta__tags" event.cancelbubble onclick="window.event.cancelBubble=!0"
                                   th:each="tag : ${post.tags}" th:href="@{${tag.status.permalink}}">
                                    <span class="tags-punctuation">#[[${tag.spec.displayName}]]</span>
                                </a>
                                <span class="article-meta__link">•</span>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 分页 -->
                <div th:replace="~{modules/widgets/page :: page(${'/tags/'+tag.spec.slug},${posts})}"></div>
            </div>
            <!-- sidebar -->
            <div th:replace="~{modules/aside :: aside(${theme.config.sidebar.tagWidgets})}"></div>
        </main>

        <!-- 底部 -->
        <footer th:replace="~{modules/footer :: footer}"></footer>
    </div>

</th:block>

</html>
